/**
 *  Nuxt.js 配置文件
 */

module.exports = {
  router: {
    linkActiveClass: 'active',
    // 自定义路由表规则
    extendRoutes(routes, resolve) {
      // 清空默认的路由表
      // routes = [] 无法清空
      routes.splice(0)
      // 插入自己的路由表
      routes.push(...[{
        path: '/',
        component: resolve(__dirname, 'pages/layout/'),
        children: [{
            path: '', // 默认子路由
            name: 'home',
            component: resolve(__dirname, 'pages/home/'),
          },
          {
            path: '/login',
            name: 'login',
            component: resolve(__dirname, 'pages/login/'),
          },
          {
            path: '/register',
            name: 'register',
            component: resolve(__dirname, 'pages/login/'),
          },
          {
            path: '/profile/:username',
            name: 'profile',
            component: resolve(__dirname, 'pages/profile/'),
          },
          {
            path: '/settings',
            name: 'settings',
            component: resolve(__dirname, 'pages/settings/'),
          },
          {
            path: '/editor',
            name: 'editor',
            component: resolve(__dirname, 'pages/editor/'),
          },
          {
            path: '/article/:id',
            name: 'article',
            component: resolve(__dirname, 'pages/article/'),
          },
        ]
      }, ])
    }
    //  extendRoutes (routes, resolve) {
    //    routes.push({
    //      name: 'custom',
    //      path: '*',
    //      component: resolve(__dirname, 'pages/404.vue')
    //    })
    //  }
  },

  // 注册插件
  plugins: [
    '~/plugins/request.js',
    '~/plugins/day.js',
  ],


  // 服务配置
  server: {
    host: '0.0.0.0',
    port: 80
  }
}